package com.zl.cms.model;

import java.util.Date;

/**
 * User: zl email:c3tc3tc3t@126.com Date: 14-1-14 Time: 上午9:00
 */
// @Entity
// @Table(name = "t_topic")
public class Topic {

  private int id;
  /**
   * 文章标题
   */
  private String title;
  /**
   * 
   * 文章关键字,通过 | 分割不同的关键字
   */
  private String keyword;

	/**
	 * 栏目名称,冗余字段
	 */
	private String cname;

  /**
   * 栏目图片id,如果该栏目是图片类型的栏目,就会显示这个id的图片
   */
  private int channelPicId;

  /**
   * 文章状态,默认为0未发布，1表示已经发布
   */
  private int status;
  /**
   * 是否是推荐的文章
   */
  private int recommend;
  /**
   * 文章内容
   */
  private String content;
  /**
   * 文章摘要
   */
  private String summary;
  /**
   * 文章作者名称,用来显示用户的昵称,冗余字段
   */
  private String author;
  /**
   * 文章所属频道,多对一
   */
  private Channel channel;
  /**
   * 文章发布者
   */
  private User user;
  /**
   * 文章发布时间
   */
  private Date publishDate;
  /**
   * 文章创建时间
   */
  private Date createDate;

  // @Column(name="channel_pic_id")
  public int getChannelPicId() {
    return channelPicId;
  }

  public void setChannelPicId(int channelPicId) {
    this.channelPicId = channelPicId;
  }

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	// @Id
  // @GeneratedValue(strategy = GenerationType.IDENTITY)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getKeyword() {
    return keyword;
  }

  public void setKeyword(String keyword) {
    this.keyword = keyword;
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public int getRecommend() {
    return recommend;
  }

  public void setRecommend(int recommend) {
    this.recommend = recommend;
  }

  public String getContent() {
    return content;
  }

  public void setContent(String content) {
    this.content = content;
  }

  public String getSummary() {
    return summary;
  }

  public void setSummary(String summary) {
    this.summary = summary;
  }

  public String getAuthor() {
    return author;
  }

  public void setAuthor(String author) {
    this.author = author;
  }

  // @ManyToOne
  // @JoinColumn(name = "cid")
  public Channel getChannel() {
    return channel;
  }

  public void setChannel(Channel channel) {
    this.channel = channel;
  }

  // @ManyToOne
  // @JoinColumn(name = "uid")
  public User getUser() {
    return user;
  }

  public void setUser(User user) {
    this.user = user;
  }

  // @Column(name = "publish_date")
  public Date getPublishDate() {
    return publishDate;
  }

  public void setPublishDate(Date publishDate) {
    this.publishDate = publishDate;
  }

  // @Column(name = "create_date")
  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }

  public Topic() {}

  public Topic(int id, String title) {
    this.id = id;
    this.title = title;
  }

	public Topic(int id, String title, String keyword, int status, int recommend, Date publishDate, String cname, String author) {
		this.id = id;
		this.title = title;
		this.keyword = keyword;
		this.status = status;
		this.recommend = recommend;
		this.publishDate = publishDate;
		this.cname = cname;
		this.author = author;
	}

	@Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Topic topic = (Topic) o;

    if (id != topic.getId()) return false;
    if (!title.equals(topic.getTitle())) return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + title.hashCode();
    return result;
  }

	@Override
	public String toString() {
		return "Topic{" +
				"id=" + id +
				", title='" + title + '\'' +
				", keyword='" + keyword + '\'' +
				", cname='" + cname + '\'' +
				", status=" + status +
				", recommend=" + recommend +
				", author='" + author + '\'' +
				", publishDate=" + publishDate +
				'}';
	}
}
